package com.open.basic;


import com.open.basic.constant.BizConstant;


public class ResponseUtil {

    private ResponseUtil() {
        throw new IllegalStateException("Utility class");
    }


    /**
     *
     * @param msg
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> fail(String msg) {
        return BaseResponse.fail(BizConstant.BIZ_EXCEPTION.getCode(), msg);
    }


    /**
     *
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> fail() {
        return BaseResponse.fail(BizConstant.BIZ_EXCEPTION.getCode(), BizConstant.BIZ_EXCEPTION.getMessage());
    }


    /**
     *
     * @param code
     * @param message
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> fail(String code, String message) {
        return BaseResponse.fail(code, message);
    }


    /**
     *
     * @param result
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> success(T result) {
        return BaseResponse.success(result);
    }


    /**
     *
     * @return
     * @param <T>
     */
    public static <T> BaseResponse<T> success() {
        return BaseResponse.success();
    }


    /**
     *
     * @param result
     * @param totalCount
     * @param pageNum
     * @param pageSize
     * @return
     * @param <T>
     */
    public static <T> PageResponse<T> success(long totalCount,T result,  int pageNum, int pageSize) {
        return PageResponse.success(totalCount,result,  pageNum, pageSize);
    }


    /**
     *
     * @param result
     * @param totalCount
     * @param pageNum
     * @param pageSize
     * @return
     * @param <T>
     */
    public static <T> PageResponse<T> success(Long totalCount,T result,   Long pageNum,  Long pageSize) {
        return PageResponse.success(totalCount,result,  pageNum.intValue(), pageSize.intValue());
    }
}
